package com.dark.index.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dark.common.web.controller.BaseController;
import com.dark.sys.service.MenuService;
import com.dark.sys.service.ResourceService;
import com.dark.sys.web.dto.MenuDto;
import com.dark.sys.web.dto.ResourceDto;

@Controller
@RequestMapping("/admin/index")
public class IndexController extends BaseController {
	
	@Autowired
	private MenuService menuService ;
	
	@Autowired
	public ResourceService resourceService ;
	
	/**
	 * 后台主页
	 */
	@RequestMapping(value={"", "/{index:index;?.*}"})
	public String index(Model model) {
		return viewName("index") ;
	}
	
	/**
	 * 菜单
	 * @param dto
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/menu")
	public List<MenuDto> menu(MenuDto dto) {
		return this.menuService.listAll(dto) ;
	}
	
	/**
	 * 菜单资源
	 * @param dto
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/resource")
	public List<ResourceDto> resource(ResourceDto dto) {
		return this.resourceService.tree(dto) ;
	}
	
	
	
	@RequestMapping(value="/welcome")
	@ResponseBody
	public void welcome(Model model) {
		//未读消息
		//最近3天的日历
	}
	
	/**
	 * 个人信息
	 * @return
	 */
	@RequestMapping(value="/ui_myinfo")
	public String ui_myinfo() {
		return viewName("ui_myinfo") ;
	}
	
	/**
	 * 修改密码
	 * @return
	 */
	@RequestMapping(value="/ui_modify_mypwd")
	public String ui_modify_mypwd() {
		return viewName("ui_modify_mypwd") ;
	}
	
}
